package com.aaa.doctor.controller;

import com.aaa.doctor.service.CareOrderItemService;
import com.aaa.doctor.vo.CareOrderVo;
import com.aaa.entity.CareHistory;
import com.aaa.entity.CareOrder;
import com.aaa.entity.CareOrderItem;
import com.aaa.entity.Patient;
import com.aaa.vo.Result;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.val;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * @version 1.8.0_181
 * @Author ZXJ
 * @Date 2023/3/25 14:31
 * @注释
 */
@RestController
@RequestMapping("/doctor/carehorderitem")
public class CareOrderItemController {
    @Resource
    private CareOrderItemService careOrderItemService;

    /**
     * 根据患者patientId查询病历信息中的处方查询
     * @param patientId
     * @return
     */
    @GetMapping("/getAllChuFang/{patientId}")
    @ApiOperation(value = "根据患者patientId查询处方")
    public Result<List<CareOrderItem>> getAllChuFang(@ApiParam(value = "患者patinetId",required = true) @PathVariable String patientId){
        return careOrderItemService.getAllChuFang(patientId);
    }





    //保存药品
    @PostMapping("/saveCareOrderItem")
    public Result<String> saveCareOrderItem(@RequestBody CareOrderVo careOrderVo){
        return careOrderItemService.saveCareOrderItem(careOrderVo);

    }
    //根据病历id(chid)查询处方信息
    @PostMapping("/queryCareOrdersByChId/{chId}")
    @ApiOperation(value = "根据chid查询处方信息")
    public Result<List<CareOrder>> queryCareOrdersByChId(@PathVariable String chId){
        return careOrderItemService.queryCareOrdersByChId(chId);
    }


    @PostMapping("/deleteCareOrderItemById/{itemId}/{amount}")
    @ApiOperation(value = "删除药品及检查详情")
    public Result<String> deleteCareOrderItemById(@PathVariable String itemId, @PathVariable BigDecimal amount){
        return careOrderItemService.deleteCareOrderItemById(itemId,amount);
    }
}
